import axios from 'axios';

const API_BASE_URL = 'http://your-api-url';

interface ServiceOrder {
  id: number;
  demandPersonName: string;
  demandPersonPhone: string;
  reservationTime: string;
  contactProvince: string;
  contactCity: string;
  contactCounty: string;
  contactAddress: string;
}

export const  getServiceOrders = async (data) => {
  const res = await axios.post<{
      total: any;
      list: any; data: { list: ServiceOrder[]; total: number } 
}>(`/demand/getServiceList`, {
   ...data
  });
  console.log(res)
  return { success : true , data : res.data.list , total : res.data.total }
};

export const addServiceOrder = (order: any) => {
  return axios.post(`/demand/addService`, order);
};

export const updateServiceOrder = (id: any, order: any) => {
  return axios.post(`/demand/updateService`, {  ...order,id:id });
};

export const deleteServiceOrder = (id: any) => {
  return axios.post(`/demand/delete`, { id });
};
// 查询详情
export const getServiceOrderDetail = (id: any) => {
  return axios.get(`/demand/getDetail`, { params:{id:id} });
};
//查询产品详情
export const getProductDetail = (id: any) => {
  return axios.get(`/demand/getAddServiceList`, { params:{mainId:id} });
};

// 短信状态列表
export const getSmsStatusList = async (id: any) => {
  const res = await axios.get(`/demandSmsLog/getList`,{params:{demandId:id}});
  return {
    success: true,
    data: res.data
  }
};

